package at.ac.thornwishstalon.ocrapp.main;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.net.Uri;
import android.os.Environment;
import android.util.Log;

public class OutputMedia {
	private static File file;
	private static final String TAG= "OutputMedia";
	
	private static File getOutputImageFile(){

		File mediaStorageDir = new File(Environment.getExternalStorageDirectory().getPath(), "OCRAPP/Pics");


		// Create the storage directory if it does not exist
		if (! mediaStorageDir.exists()){
			if (! mediaStorageDir.mkdirs()){
				Log.d(TAG, "failed to create directory");
				return null;
			}
		}

		
		// Create name
		String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
		File mediaFile;

		mediaFile = new File(mediaStorageDir.getPath() + File.separator +
				"IMG_"+ timeStamp + ".jpg");

		file=mediaFile;
		return mediaFile;
	}
	
	/** Create a file Uri for saving an image or video */
	public static Uri getOutputMediaFileUri(){
		if(file==null){
			getOutputImageFile();
		}
		return Uri.fromFile(file);
	}

}
